<?
$page_title="My SEVA Commitments to Mera BABA ";
$mindex=1;
$profile_menu=1;
?>
<?include("includes/header.php") ?>
<script src="prototype.js" language="javascript"></script>
<?
$memberId=getMemberId();
$curTime=getIndianDateTime();

if($_REQUEST["commit_id"]!="" && $_POST){

qry_data("update bkitc_member_commitment set rec_status=0,last_updated='".$curTime."' where commit_id=".$_REQUEST["commit_id"]);
}
if($_REQUEST["mode"]=="add" && $_POST){




foreach($_POST as $key => $value) { $arr_data[$key]=$value;}
foreach($arr_data as $key => $value) { $arr_data[$key]=addslashes($value); }

$event_id=$_GET["event_id"];
//$event_info=@array_pop(qry_data("select * from bkit_news where rec_status>=1 and news_id=".$event_id));
$arr_data["rec_status"]=1;
$arr_data["created_date"]=$curTime;
$arr_data["member_id"]=$memberId;
$arr_data["last_updated_by"]="member".$memberId;
$commitment_id=insert_qry("bkitc_member_commitment",$arr_data);


}
?>

<div class="cleardiv" style="margin-top:30px"></div>
Write your commitment here.<br/>
<form method="post" action="mycommitment.php?mode=add" name="frmcommit">
	<textarea class="txtarea" rows="3" style="width:100%" name="message" id="message"></textarea>
	<input type="hidden" name="commit_id" value="" />
</form>
<div style="float:right;clear:both;font-weight:bold;padding-top:5px;" class="button" onclick="document.frmcommit.submit()">Add Commitment</div>
<div class="cleardiv"></div>

<div class="page_subtitle">
<u>Commitments done so far :</u></div>
<div class="cleardiv"></div>
<?
$query="select * from bkitc_member_commitment where rec_status>=1 and member_id=".$memberId;
$commitmentInfo=qry_data($query);
?>

<div class="commitment">
<? foreach($commitmentInfo as $k=>$info){ ?>
<div class="item">
<div class="fleft">Commitment made on : <?=$info["created_date"]?> </div>
 <div class="fright"><a href="javascript:;" onclick="document.frmcommit.commit_id.value=<?=$info["commit_id"]?>;document.frmcommit.submit();">Delete this Commitment</a>
</div>
<div class="cleardiv"></div>
<br/>
<div class="msg"><?=$info["message"]?></div><br/>

<div onclick="$('plans_<?=$info["commit_id"]?>').toggle()" style="cursor:pointer">
<b><u>Action Plans :</u></b>
</div>
<div class="fright"><a href="javascript:;" onclick="$('dvActionPlan_<?=$info["commit_id"]?>').toggle();">Add Action Plan to this Commitment</a></div>
<form method="post" action="commitment_pro.php?commit_plan_id=" >
<div id="dvActionPlan_<?=$info["commit_id"]?>" style="display:none"><br/>
Write your Action Plan here :<br/>
<textarea class="txtarea" rows="4" style="width:100%" name="actionplan" id="actionplan"></textarea>
	<input type="hidden" value="<?=$info["commit_id"]?>" name="commit_id"/>
	<div class="fleft">
	<input type="submit"  class="button"  value="Add Plan" />
	</div>
</div>
</form>
<div>
<div class="cleardiv"></div>
<?

$planinfo=qry_data("select * from bkitc_member_actionplan where commit_id=".$info["commit_id"]);

?>
<div id="plans_<?=$info["commit_id"]?>">
<? foreach($planinfo as $m=>$info1){ ?>
<p><b>Action : <?=$m+1?></b></p>
<p><?=$info1["actionplan"]?></p>
<? } ?>
</div>

</div>


<div>
	<div class="cleardiv"></div>
</div>

</div>



<?}?>
</div>


<?include("includes/footer.php") ?>